home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / realstr.com / REALSTR.DOC < prev    next >
Encoding:
Text File  |  1990-07-05  |  3.7 KB  |  103 lines

  1.  
  2.      Files in this archive:
  3.     RealStr.Doc  - This file
  4.     RealStr.Pas  - Unit containing the RealToString () function
  5.     Test.    Pas  - RealToString example - type 0 or letter to exit
  6.  
  7.  
  8.     RealToString formats a floating point double, real, or single number
  9. into a string, according to the requested number of significant digits.
  10.  
  11.  
  12.     The number is displayed without the use of scientific notation, if
  13. it is possible to do so and still display the requested number of significant
  14. digits.  Also the number is rounded at the number of significant digits + 1
  15. and all trailing zeros are removed.
  16.  
  17.  
  18.     Because many numbers represented in a base 2 floating point format
  19. do not have an exact equivalent in base 10, any rounding done to a base 2
  20. number, which is then converted by Str() to a base 10 string, will be
  21. ineffective.  To bypass this problem, RealStr uses Str to convert the
  22. floating point number to a base 10 string and then rounds and formats the
  23. string.
  24.  
  25.  
  26.     Test.exe gives an example of how the routine is used and what the
  27. results look like for different significant digits.  Also, running Test.exe
  28. for several numbers will give the user an idea of why the TP reference guide
  29. says the significant digits of a single type are 7 TO 8, a real type 11 TO 12,
  30. and a double type 15 TO 16.
  31.  
  32.  
  33.         Example of using RealToString vs. Str :
  34.  
  35. var
  36. TempStr : string;
  37. Number    : real;
  38.  
  39.    begin
  40.    Number := 5.1;
  41.    Str (Number, TempStr);           { TempStr = '5.09999...E 0000'       }
  42.                        { 5.1 cannot be represented exactly  }
  43.                        { as a single or real type number    }
  44.    Number := 0.01;
  45.    Str (Number, TempStr);           { TempStr = '1.00000...E-0002'       }
  46.    end;
  47.  
  48.  
  49.    begin
  50.    Number := 5.1;
  51.    TempStr :=  RealToString (11, Number);      { TempStr = '5.1'         }
  52.  
  53.    Number := 0.01;
  54.    TempStr :=  RealToString (11, Number);      { TempStr = '0.01'        }
  55.    end;
  56.  
  57.  
  58.  
  59.     This routine is released to public domain by the author on 7/5/90.
  60.  
  61.     If you find any bugs in the routine, please drop me a note by
  62. Compuserve EMAIL.  Thanks.
  63.  
  64.  
  65.                    Rich Mullen    76566,1325
  66.  
  67.  
  68.  
  69.          ----------------end-of-author's-documentation---------------
  70.  
  71.                         Software Library Information:
  72.  
  73.                    This disk copy provided as a service of
  74.  
  75.                         The Public (Software) Library
  76.  
  77.          We are not the authors of this program, nor are we associated
  78.          with the author in any way other than as a distributor of the
  79.          program in accordance with the author's terms of distribution.
  80.  
  81.          Please direct shareware payments and specific questions about
  82.          this program to the author of the program, whose name appears
  83.          elsewhere in  this documentation. If you have trouble getting
  84.          in touch with the author,  we will do whatever we can to help
  85.          you with your questions. All programs have been tested and do
  86.          run.  To report problems,  please use the form that is in the
  87.          file PROBLEM.DOC on many of our disks or in other written for-
  88.          mat with screen printouts, if possible.  The P(s)L cannot de-
  89.          bug programs over the telephone.
  90.  
  91.          Disks in the P(s)L are updated monthly, so if you did not get
  92.          this disk  directly from the P(s)L,  you should be aware that
  93.          the files in this set may no  longer be the current versions.
  94.  
  95.          For a copy of the latest monthly software library newsletter
  96.          and a list of the 2,000+ disks in the library, call or write
  97.  
  98.                         The Public (Software) Library
  99.                               P.O.Box 35705
  100.                            Houston, TX 77235-5705
  101.                                (713) 524-6394
  102.  
  103.